<?php

namespace Database\Seeders;

use Illuminate\Database\Seeder;
use Illuminate\Support\Facades\DB;

class AdminMenuSeeder extends Seeder
{
    /**
     * Run the database seeds.
     *
     * @return void
     */
    public function run()
    {
        $datas = [
            [
                'parent_id'  => 0,
                'title'      => '首页',
                'path'       => '/',
                'icon'       => 'el-icon-s-home',
                'sort'       => 1,
                'created_at' => date('Y-m-d H:i:s'),
                'updated_at' => date('Y-m-d H:i:s'),
            ],
            [
                'parent_id'  => 0,
                'title'      => '系统管理',
                'path'       => '/',
                'icon'       => 'el-icon-setting',
                'sort'       => 2,
                'created_at' => date('Y-m-d H:i:s'),
                'updated_at' => date('Y-m-d H:i:s'),
            ],
            [
                'parent_id'  => 2,
                'title'      => '用户管理',
                'path'       => '/system/user/index',
                'icon'       => 'el-icon-user',
                'sort'       => 3,
                'created_at' => date('Y-m-d H:i:s'),
                'updated_at' => date('Y-m-d H:i:s'),
            ],
            [
                'parent_id'  => 2,
                'title'      => '角色管理',
                'path'       => '/system/role/index',
                'icon'       => 'el-icon-s-check',
                'sort'       => 4,
                'created_at' => date('Y-m-d H:i:s'),
                'updated_at' => date('Y-m-d H:i:s'),
            ],
            [
                'parent_id'  => 2,
                'title'      => '权限管理',
                'path'       => '/system/permission/index',
                'icon'       => 'el-icon-unlock',
                'sort'       => 5,
                'created_at' => date('Y-m-d H:i:s'),
                'updated_at' => date('Y-m-d H:i:s'),
            ],
            [
                'parent_id'  => 2,
                'title'      => '菜单栏管理',
                'path'       => '/system/menu/index',
                'icon'       => 'el-icon-menu',
                'sort'       => 6,
                'created_at' => date('Y-m-d H:i:s'),
                'updated_at' => date('Y-m-d H:i:s'),
            ]
        ];
        DB::transaction(function () use ($datas) {
            foreach ($datas as $data) {
                DB::table('admin_menus')->insert($data);
            }
        });
    }
}
